/*
 * IndexBuilderTest.java
 *
 * Created on September 24, 2007, 4:39 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package uk.ac.ebi.bioinvindex.search;

import org.dbunit.operation.DatabaseOperation;
import org.junit.Before;
import org.junit.Test;
import uk.ac.ebi.bioinvindex.dao.ejb3.DBUnitEJB3DAOTest;
import uk.ac.ebi.bioinvindex.search.hibernatesearch.StudyFreeTextSearchImpl;
import uk.ac.ebi.bioinvindex.utils.mock.TestSetIndexBuilder;

import static java.lang.System.out;

/**
 * Run
 *   mvn -Dtest=indexTestSet test
 *
 * and the current database will be reindexed
 * @author brandizi
 */
public class indexTestSet extends DBUnitEJB3DAOTest
{
	private StudyFreeTextSearchImpl search;


	public indexTestSet () throws Exception {
	}

	protected void prepareSettings() {
		beforeTestOperations.add(DatabaseOperation.CLEAN_INSERT);
		dataSetLocation = "ae_study-data.xml";
	}

	@Before
	public void setUp ()
	{
		search = new StudyFreeTextSearchImpl ();
		search.setEntityManager ( this.entityManager );
	}


	@Test
	public void run ()
	{
		out.println ( "*** Indexing the database" );
		TestSetIndexBuilder idxBuild = new TestSetIndexBuilder ();
		idxBuild.setEntityManager ( this.entityManager );
		idxBuild.indexAll ();
		out.println ( "\n\n*** Done" );
	}

}
